package com.unit4science;

import java.util.List;

import android.app.Application;
import android.content.Context;

import com.entities.Chart;
import com.entities.Unit;

/* 
 * Phai cau hinh Main Application trong AndroidMagifest.xml
 * <application
 android:icon="@drawable/ic_launcher"
 android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
 android:label="@string/app_name" 
 android:name=".Main">
 */
public class Main extends Application {
	private static Context context;
	public static List<Chart> charts;

	@Override
	public void onCreate() {
		super.onCreate();
//		Log.i("Main", "onCreate");
		context = this.getApplicationContext();

		charts = Chart.getCharts();
	}

	public static String getChartNameFromResource(int resource) {
		return Main.getContext().getResources().getString(resource);
	}

	public static Chart getChartAtIndex(int index) {
		return charts.get(index);
	}

	public static List<Unit> getUnitListFromChartAtIndex(int index) {
		// mac dinh ban dau Chart thu 0 duoc chon
		Chart chart = Main.getChartAtIndex(index);
		// load units cua chart len ListView
		return chart.getUnits();		
	}

	public static Context getContext() {
		return context;
	}
}
